package com.dingding.study.controller;


import com.dingding.study.DTO.BannerGroupTagDTO;
import com.dingding.study.annotation.ApiLog;
import com.dingding.study.service.事务失效.TransactionTestImpl;
import com.dingding.study.service.责任链模式.payImpl.PayHandlerChain;
import lombok.extern.slf4j.Slf4j;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class PayController {

    @Autowired
    private PayHandlerChain payHandlerChain;

    @Autowired
    private TransactionTestImpl transactionTest;

    @GetMapping("/pay")
    public String index(@RequestParam("payType") String payType){
       return payHandlerChain.pay(payType);
    }

    @GetMapping("/hello")
    public BannerGroupTagDTO hello(){
        BannerGroupTagDTO bannerGroupTagDTO = new BannerGroupTagDTO();
        return bannerGroupTagDTO;
    }

    @GetMapping("/transaction")
    public void test(){
//        TransactionTestImpl bean = applicationContext.getBean(TransactionTestImpl.class);
        System.out.println("controller下是否代理类:"+ AopUtils.isAopProxy(transactionTest));
//        System.out.println("controller下是否代理类:"+AopUtils.isAopProxy(bean));
        transactionTest.insertUser();
    }

    @GetMapping("/aop")
    @ApiLog(moduleName = "支付模块", methodDesc = "获取支付返回结果")
    public String recordLog(@RequestParam("uuid") String uuid){
        return "获取支付返回结果";
    }



}
